<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        "use strict"
        var dog={name:"狗狗"};
        //{value: '狗狗', writable: true, enumerable: true, configurable: true}
        console.log(Object.getOwnPropertyDescriptor(dog,"name"));

        //定义color属性
        Object.defineProperty(dog,"color",{
            value:"白色",  //值
            writable:false,  //是否可写
            enumerable:false,  //是否可枚举
            configurable:false  //是否可删除
        });
        for(var key in dog){
            console.log(key,dog[key]);  //不能枚举出color的值
        }
        delete dog.color;  //Cannot delete property 'color'
        dog.color="黑色";  //不能修改
        console.log(dog.color);

    </script>
</body>
</html>